#ifndef BATTLE_H
#define BATTLE_H

#include <QPushButton>
#include <QWidget>
#include <Qstring>
#include <QMediaPlayer>
#include "pokemon.h"

namespace Ui {
class battle;
}


class battle : public QWidget
{
    Q_OBJECT

public:
    explicit battle(QWidget *parent = nullptr);
    ~battle();
    void setPlayerPokemon(Pokemon *pokemon);
    void setEnemyPokemon(Pokemon *pokemon);
    void startBattle();
    Ui::battle *ui;

    void addplayer(Pokemon* pokemon);
    void addenemy(Pokemon* pokemon);
    void playSkillSound(Skill* skill);

signals:
    void back(); //定义一个用来返回的信号

private slots:
    void on_runButton_clicked();
    void on_skillButton1_clicked();
    void on_skillButton2_clicked();
    void on_skillButton3_clicked();
    void on_skillButton4_clicked();
    void onSkillUsed(int index, Pokemon *user);
    void onFainted();

    void onFaintedenemy();
    void switchpokemon();
    void stop1(); // 暂停同函数

private:
    Pokemon *m_playerPokemon;
    Pokemon *m_enemyPokemon;
    QVector<Pokemon *> m_playerTeam; //我方队伍
    QVector<Pokemon *> m_enemyTeam;  //敌方队伍
    int playermax = 0;
    int player = 0; //我方队伍索引
    int enemymax = 0;
    int enemy = 0; //敌方队伍索引

    bool m_isPlayerTurn;

    void updateUI();
    void enemyTurn();
    void checkBattleEnd();
    QString defendername(Pokemon *user);
    void hideswitch();
    bool allalived(QVector<Pokemon*> m_playerTeam);
    QMediaPlayer* m_skillPlayer;
};

#endif // BATTLE_H
